public class ReplyWeiboColtorl {

    public Weibo_Comment__c record {get;set;}
    private Map<String, String> param = ApexPages.currentPage().getParameters();
    public String options {get;set;}
    
    public ReplyWeiboColtorl(){
        record = new Weibo_Comment__c();
        record.WBID__c = param.get('mid');
        record.Weibo_Conversation__c = param.get('wid');
    }
    
    /// get Solution__s as Select Option
    public List<SelectOption> getSolutionOptions(){
        List<SelectOption> options = new List<SelectOption>();
        List<Solution__c> solutions = [SELECT ID,Name,Content__c FROM Solution__c ];
        
        for( Solution__c slt : solutions){
                options.add( new SelectOption( slt.Content__c  ,  slt.Name) );
        }
        return options;
    }
    
    public void replyWeibo(){
        
        record = new Weibo_Comment__c();
        record.WBID__c = ApexPages.currentPage().getParameters().get('mid');
        record.Weibo_Conversation__c = ApexPages.currentPage().getParameters().get('wid');
        
        String jsonResult = '';
        String content =  ApexPages.currentPage().getParameters().get('content');
        system.debug('@@@@@@@@@@@@@@@@@@@@@@@@@@  ID :  '+ record.WBID__c);
        system.debug('@@@@@@@@@@@@@@@@@@@@@@@@@@  CN :  '+ content); 
         
        if( record.WBID__c!=null && record.WBID__c.length()>10 ){
                
            record.Reply_Content__c = content;
            WB_OpenApi.WB_Comment_Create_In wbc_in = new WB_OpenApi.WB_Comment_Create_In();
            wbc_in.id = record.WBID__c ;
            wbc_in.comment = record.Reply_Content__c ;
            
            jsonResult = wbc_in.toRequestURL();
            system.debug('@@@@@@@@@@@@@@@@@@@@@@@@@@  :  '+ content);
            system.debug('@@@@@@@@@@@@@@@@@@@@@@@@@@  :  '+ jsonResult);
        }
        
        if( jsonResult.contains( record.Reply_Content__c) ){
            record.Status__c = 'sent';
        }else{
            record.Status__c = 'fail';
        }
        insert record;
                
    }

    
    
    
/**
    // reply a Weibo
    public String status { get; set; }
    public String resultJson {get;set;}
    public String wbid{get;set;}
    public String comment{get;set;}
    
    public String replyWeibo() {
        
        WB_OpenApi.WB_Comment_Create_In WB_Create = new WB_OpenApi.WB_Comment_Create_In();
        WB_Create.id = wbid;
        WB_Create.comment = '';

        // resultJson = WB_Create.toRequestURL();
        status = 'success!';
        return 'WBID:='+wbid+'COMMENT:='+comment;
    }
**/
}